# 自定义异常并抛出

class ShortInputException(Exception):
    """自定义的异常"""

    def __init__(self, length, atleast):
        Exception.__init__(self)
        self.length = length
        self.atleast = atleast


try:
    text = input("enter text >>")
    if len(text) < 3:
        raise ShortInputException(len(text), 3)
except EOFError:
    print("eof")
except ShortInputException as ex:
    print(('ShortInputException: the is {} long,' +
           'expected at least {}').format(ex.length, ex.atleast))
else:
    print('no exception')

